<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            var combinationSum4 = function (nums, target) {
                let bagSize = target
                let dp = new Array(bagSize + 1).fill(0)
                dp[0] = 1
                for (let j = 0; j <= bagSize; j++) {
                    for (let i = 0; i < nums.length; i++) {
                        if (j >= nums[i]) {
                            dp[j] += dp[j - nums[i]]
                        }
                    }
                }
                return dp[bagSize]
            }
        </script>
    </body>
</html>
